print("我的名字是%s，我的学号是%s"%("董家萁","0306201106"))
import random
def guess_number_game():
    # 随机生成一个1-100之间的整数
    number_to_guess = random.randint(1, 100)
    guesses_left = 5
    guess = None

    print("我已经想好了一个1到100之间的数，你有5次机会来猜它。")
    while guesses_left > 0:
        try:
            guess = int(input("请输入你的猜测："))
            if 1 <= guess <= 100:
                if guess < number_to_guess:
                    print("比这个大！")
                elif guess > number_to_guess:
                    print("比这个小！")
                else:
                    print("棒！你猜对了！")
                    return
            else:
                print("请输入一个1到100之间的数。")
                continue  # 如果输入的不是数字或不在范围内，则重新循环
        except ValueError:
            print("请输入一个有效的数字。")
            continue  # 如果输入无法转换为整数，则重新循环

        guesses_left -= 1
        if guesses_left == 0:
            print(f"这局你输了！正确的数是 {number_to_guess}")
if __name__ == "__main__":
    guess_number_game()
